//
//  WKNotificationView.m
//  WKMaybell
//
//  Created by 何文虎 on 2019/3/1.
//  Copyright © 2019 何文虎. All rights reserved.
//

@interface WKNotificationListCell : UITableViewCell
@property(nonatomic,strong)UILabel *titleLb;
@property(nonatomic,strong)UILabel *timeLb;
@property(nonatomic,strong)UILabel *detaileLb;
@end

@implementation WKNotificationListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self createUI];
    }
    return self;
}

- (void)createUI{
    
    self.backgroundColor = BACKGROUND_COLOR;
    UIView *bgview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, 68)];
    bgview.backgroundColor = [UIColor whiteColor];
    [self.contentView addSubview:bgview];
    
    [bgview addSubview:self.titleLb];
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_offset(12);
        make.top.mas_offset(15);
        make.size.mas_equalTo(CGSizeMake(70, 14));
    }];
    
    [bgview addSubview:self.timeLb];
    [self.titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_offset(-12);
        make.top.mas_offset(15);
        make.size.mas_equalTo(CGSizeMake(70, 14));
    }];
    
    [bgview addSubview:self.detaileLb];
    [self.detaileLb mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.titleLb.mas_bottom).offset(12);
        make.left.mas_equalTo(12);
        make.right.mas_offset(-12);
        make.bottom.mas_offset(-15);
       
    }];
    
    _titleLb.text = @"系统通知";
    _timeLb.text = @"5小时前";
    _detaileLb.text = @"你的好友可爱的秘密在日记中更新了一组照片,快去看看他最美的照片吧.去吧孩子";
    
}

- (UILabel*)titleLb{
    if (!_titleLb) {
        _titleLb = [[UILabel alloc]init];
        _titleLb.textColor = TitleColor;
        _titleLb.font = PFSC_MediumFont(15);
    }
    return _titleLb;
}

- (UILabel*)timeLb{
    if (!_timeLb) {
        _timeLb = [[UILabel alloc]init];
        _timeLb.textColor = TimeColor;
        _timeLb.font = PFSC_MediumFont(11);
        _timeLb.textAlignment = NSTextAlignmentRight;
    }
    return _timeLb;
}

- (UILabel*)detaileLb{
    if (!_detaileLb) {
        _detaileLb = [[UILabel alloc]init];
        _detaileLb.textColor = TimeColor;
        _detaileLb.font = PFSC_MediumFont(12);
        
    }
    return _detaileLb;
}


@end

#import "WKNotificationView.h"

@interface WKNotificationView ()<UITableViewDelegate,UITableViewDataSource>
@property(nonatomic,strong)UITableView *tableView;
@end

@implementation WKNotificationView


- (instancetype)initWithFrame:(CGRect)frame{
    if (self ==[super initWithFrame:frame]) {
        [self setupWithFrame:frame];
    }
    return self;
}

- (void)setupWithFrame:(CGRect)frame{
    self.tableView = [[UITableView alloc]initWithFrame:frame style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self addSubview:_tableView];
    _tableView.backgroundColor = BACKGROUND_COLOR;
    [_tableView registerClass:[WKNotificationListCell class] forCellReuseIdentifier:NSStringFromClass([WKNotificationListCell class])];
    _tableView.tableFooterView = [UIView new];
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    WKNotificationListCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([WKNotificationListCell class]) forIndexPath:indexPath];
    return cell;
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 80;
}


@end
